package com.gin.kotlin.no_gay_alliance.adapter.user

import android.content.Context
import com.gin.kotlin.no_gay_alliance.base.AbstractBindingRecyclerViewAdapter
import com.gin.kotlin.no_gay_alliance.base.MyHandler
import com.gin.kotlin.no_gay_alliance.databinding.ItemIpLocationHistoryBinding
import com.gin.kotlin.no_gay_alliance.model.IpLocationRange
import com.gin.kotlin.no_gay_alliance.utils.TimeUtils

class IpLocationRangeAdapter(context: Context, handler: MyHandler) : AbstractBindingRecyclerViewAdapter<ItemIpLocationHistoryBinding, IpLocationRange>(context, handler) {
    override fun onBindViewHolder(holder: ViewHolder<ItemIpLocationHistoryBinding>, position: Int, b: ItemIpLocationHistoryBinding, dataModel: IpLocationRange) {
        b.tvIpLocation.text = dataModel.location
        // 创建时间文字，颜色
        val start = TimeUtils.SIMPLE_DATE_TIME_FORMATTER.format(dataModel.start)
        val end = TimeUtils.SIMPLE_DATE_TIME_FORMATTER.format(dataModel.end)
        b.tvTimestamp.text = "$start - ${end}"
    }
}